Skip to main content

Chapter 23 - Terraform apply -refresh only

Updating your Terraform against Azure

terraform refresh


This command has been deprecated out. It used to exist to refresh the infrastructure, but is generally considered unsafe because of the way it communicates with the provider and automatically applies changes to the infrastructure. this command is basically a refresh and apply with an -auto-approve.

To fix this, Terraform introduced the terraform apply -refresh-only option.

terraform plan and apply -refresh-only


This will update your state file with the changes that are in your cloud, but it will not update the .tf files with the correct information. You will then manually need to update the .tf files with the changes to match state.

Reference the state file and then add it to the .tf file.